home *** CD-ROM | disk | FTP | other *** search
/ Linux Cubed Series 2: Applications / Linux Cubed Series 2 - Applications.iso / editors / emacs / xemacs / xemacs-1.004 / xemacs-1 / xemacs-19.13 / lwlib / lwlib.h < prev    next >
Encoding:
C/C++ Source or Header  |  1995-06-29  |  5.5 KB  |  185 lines

  1. #ifndef LWLIB_H
  2. #define LWLIB_H
  3.  
  4. #include <X11/Intrinsic.h>
  5.  
  6. /* To eliminate use of `const' in the lwlib sources, define CONST_IS_LOSING. */
  7. #undef CONST
  8. #ifdef CONST_IS_LOSING
  9. # define CONST
  10. #else
  11. # define CONST const
  12. #endif
  13.  
  14. /*
  15. ** Widget values depend on the Widget type:
  16. ** 
  17. ** widget:   (name    value   key enabled data contents/selected)
  18. **
  19. ** label:    ("name" "string" NULL  NULL NULL NULL)
  20. ** BUTTON:   ("name" "string" "key" T/F  data <default-button-p>)
  21. ** CASCADE (button w/menu): 
  22. **           ("name" "string" "key" T/F  data (label|button|button w/menu...))
  23. ** INCREMENTAL (button w/menu construction callback): 
  24. **           ("name" "string" NULL  T/F  <opaque pointer>)
  25. ** menubar:  ("name" NULL     NULL  T/F  data (button w/menu))
  26. ** scrollbar:("name" NULL     NULL  T/F  NULL NULL)
  27. ** selectable thing:
  28. **           ("name" "string" "key" T/F  data T/F)
  29. ** checkbox: selectable thing
  30. ** radio:    ("name" NULL     NULL  T/F  data (selectable thing...))
  31. ** strings:  ("name" NULL     NULL  T/F  data (selectable thing...))
  32. ** TEXT:     ("name" "string" <ign> T/F  data)
  33. **
  34. ** Note that the above is EXTREMELY bogus.  The "type" of the various entities
  35. ** that a widget_value structure can represent is implicit in the contents of
  36. ** half a dozen slots, instead of there simply being a type field.  This 
  37. ** should all be rethunk.  I've added a type field, but for now it's only used
  38. ** by the new xlwmenu code.
  39. */
  40.  
  41. typedef unsigned long LWLIB_ID;
  42.  
  43. typedef enum _change_type
  44. {
  45.   NO_CHANGE = 0,
  46.   INVISIBLE_CHANGE = 1,
  47.   VISIBLE_CHANGE = 2,
  48.   STRUCTURAL_CHANGE = 3
  49. } change_type;
  50.  
  51. typedef enum _widget_value_type
  52. {
  53.   UNSPECIFIED_TYPE = 0,
  54.   BUTTON_TYPE = 1,
  55.   TOGGLE_TYPE = 2,
  56.   RADIO_TYPE = 3,
  57.   TEXT_TYPE = 4,
  58.   SEPARATOR_TYPE = 5,
  59.   CASCADE_TYPE = 6,
  60.   PUSHRIGHT_TYPE = 7,
  61.   INCREMENTAL_TYPE = 8
  62. } widget_value_type;
  63.  
  64. typedef enum _scroll_action
  65. {
  66.   SCROLLBAR_LINE_UP = 0,
  67.   SCROLLBAR_LINE_DOWN = 1,
  68.   SCROLLBAR_PAGE_UP = 2,
  69.   SCROLLBAR_PAGE_DOWN = 3,
  70.   SCROLLBAR_DRAG = 4,
  71.   SCROLLBAR_CHANGE = 5,
  72.   SCROLLBAR_TOP = 6,
  73.   SCROLLBAR_BOTTOM = 7
  74. } scroll_action;
  75.  
  76. typedef struct _scroll_event
  77. {
  78.   scroll_action action;
  79.   int slider_value;
  80.   Time time;
  81. } scroll_event;
  82.  
  83. typedef struct _scrollbar_values
  84. {
  85.   int line_increment;
  86.   int page_increment;
  87.  
  88.   int minimum;
  89.   int maximum;
  90.  
  91.   int slider_size;
  92.   int slider_position;
  93.  
  94.   int scrollbar_width, scrollbar_height;
  95.   int scrollbar_x, scrollbar_y;
  96. } scrollbar_values;
  97.  
  98. typedef struct _widget_value
  99. {
  100.   /* This slot is only partially utilized right now. */
  101.   widget_value_type type;
  102.  
  103.   /* name of widget */
  104.   char*        name;
  105.   /* value (meaning BOGUSLY depend on widget type) */
  106.   char*        value;
  107.   /* keyboard equivalent. no implications for XtTranslations */ 
  108.   char*        key;
  109.   /* true if enabled */
  110.   Boolean    enabled;
  111.   /* true if selected */
  112.   Boolean    selected;
  113.   /* true if was edited (maintained by get_value) */
  114.   Boolean    edited;
  115.   /* true if has changed (maintained by lw library) */
  116.   change_type    change;
  117.   /* Contents of the sub-widgets, also selected slot for checkbox */
  118.   struct _widget_value*    contents;
  119.   /* data passed to callback */
  120.   XtPointer    call_data;
  121.   /* next one in the list */
  122.   struct _widget_value*    next;
  123.   /* slot for the toolkit dependent part.  Always initialize to NULL. */
  124.   void* toolkit_data;
  125.   /* tell us if we should free the toolkit data slot when freeing the
  126.      widget_value itself. */
  127.   Boolean free_toolkit_data;
  128.  
  129.   /* data defining a scrollbar; only valid if type == "scrollbar" */
  130.   scrollbar_values *scrollbar_data;
  131.  
  132.   /* we resource the widget_value structures; this points to the next
  133.      one on the free list if this one has been deallocated.
  134.    */
  135.   struct _widget_value *free_list;
  136. } widget_value;
  137.  
  138.  
  139. typedef void (*lw_callback) (Widget w, LWLIB_ID id, XtPointer data);
  140.  
  141. void  lw_register_widget (CONST char* type, CONST char* name, LWLIB_ID id,
  142.               widget_value* val, lw_callback pre_activate_cb,
  143.               lw_callback selection_cb,
  144.               lw_callback post_activate_cb);
  145. Widget lw_get_widget (LWLIB_ID id, Widget parent, Boolean pop_up_p);
  146. Widget lw_make_widget (LWLIB_ID id, Widget parent, Boolean pop_up_p);
  147. Widget lw_create_widget (CONST char* type, CONST char* name, LWLIB_ID id,
  148.              widget_value* val, Widget parent, Boolean pop_up_p,
  149.              lw_callback pre_activate_cb,
  150.              lw_callback selection_cb,
  151.              lw_callback post_activate_cb);
  152. LWLIB_ID lw_get_widget_id (Widget w);
  153. int lw_map_widget_values (LWLIB_ID id, int (*mapfunc) (widget_value *value,
  154.                                void *closure),
  155.               void *closure);
  156. void lw_modify_all_widgets (LWLIB_ID id, widget_value* val, Boolean deep_p);
  157. void lw_destroy_widget (Widget w);
  158. void lw_destroy_all_widgets (LWLIB_ID id);
  159. void lw_destroy_everything (void);
  160. void lw_destroy_all_pop_ups (void);
  161. Widget lw_raise_all_pop_up_widgets (void);
  162. widget_value* lw_get_all_values (LWLIB_ID id);
  163. Boolean lw_get_some_values (LWLIB_ID id, widget_value* val);
  164. void lw_pop_up_all_widgets (LWLIB_ID id);
  165. void lw_pop_down_all_widgets (LWLIB_ID id);
  166.  
  167. widget_value *malloc_widget_value (void);
  168. void free_widget_value (widget_value *);
  169. widget_value *replace_widget_value_tree (widget_value*, widget_value*);
  170.  
  171. void lw_popup_menu (Widget, XEvent *);
  172.  
  173. /* Defined in menubar-x.c in ../src.  We put it here because it is the
  174.    one header which knows what a widget_value is and which is also
  175.    included everywhere this is used.  Don't use this in lwlib. */
  176. widget_value *xmalloc_widget_value (void);
  177.  
  178. /* Toolkit independent way of focusing on a Widget at the Xt level. */
  179. void lw_set_keyboard_focus (Widget parent, Widget w);
  180.  
  181.  /* Silly Energize hack to invert the "sheet" button */
  182. void lw_show_busy (Widget w, Boolean busy);
  183.  
  184. #endif /* LWLIB_H */
  185.